use serde::Deserialize;
use serde::Serialize;
use ts_rs::TS;
use yata::core::PeriodType;
use yata::core::ValueType;

use super::IndicatorActionWrap;

///
/// Struct to hold the results of Struct yata::indicators::KeltnerChannel

///
///  参见[KNC](https://en.wikipedia.org/wiki/Keltner_channel)
///
#[derive(Serialize, Deserialize, Default, Debug, TS, Clone)]
#[ts(export)]
pub struct KNC {
    ///  1 signal
    /// When source value goes above the upper bound, then returns full buy signal.
    ///  When source value goes under the lower bound, then returns full sell signal.
    /// Otherwise returns no signal.
    pub signal0: Option<IndicatorActionWrap>,

    ///3 values
    ///upper bound
    ///Range of values is the same as the range of the source values.
    ///
    pub upper: ValueType,
    ///source value
    pub source: ValueType,
    ///lower bound
    ///Range of values is the same as the range of the source values.
    pub lower: ValueType,
}

/// Configuration
#[derive(Serialize, Deserialize, Debug, TS, Clone, Copy)]
#[ts(export)]
pub struct KNCConfig {
    ///ma: M
    ///Middle moving average type.
    ///
    ///Default is EMA(20).
    ///
    ///Period range in [2; PeriodType::MAX).
    pub ma: PeriodType,
    ///sigma: ValueType
    ///True range multiplier. Default is 1.0.
    ///
    ///Range in (0.0; +inf)    
    pub sigma: ValueType,
    // pub source: Source,
}

impl Default for KNCConfig {
    fn default() -> Self {
        Self {
            ma: 20,
            sigma: 1.0,
            //  source: Source::Close,
        }
    }
}
